<template>
	<view class="content">
		<view class="box">
			<view class="form-item flexBC">
				<view class="name">手机号/工号</view>
				<view class="value">
					<input type="text" v-model="params.username" placeholder="请输入手机号/工号" />
				</view>
			</view>
			<view class="form-item flexBC">
				<view class="name">密码</view>
				<view class="value">
					<input class="uni-input" password v-model="params.password" type="text" placeholder="请输入密码" />
				</view>
			</view>
		</view>
		<footer-button btnTip='登录账号' @clickFooter='bindNo'></footer-button>
		<uni-popup ref="myPopup" :mask-click="false">
			 <view class="popup-content">
				<view class="popup-title">温馨提示</view>
				<view class="popup-tip-info">
					用户不存在，请联系公司
				</view>
				<view class="popup-btns">
					<button class="btn" type="primary"  @click="$refs.myPopup.close()">我知道了</button>
				</view>
			 </view>
		</uni-popup>
	</view>
</template>

<script>
	import {doLogin} from '@/untils/api.js'
	export default {
		data() {
			return {
				params:{
					username:'',  //18398433039
					password:'' //123456
				}
			};
		},
		methods:{
			bindNo(){
				const {username,password} = this.params
				let title = ''
				if(!username){
					title = '请输入手机号/工号'
				}
				if(!password){
					title = '请输入密码'
				}
				// uni.navigateTo({
				// 	url:'/subpackage/login/login'
				// })
				if(title){
					uni.showToast({
						icon:'none',
						title
					})
					return false;
				}
				doLogin(this.params).then((res) => {
					console.log(res)
					
					const {code,data,msg} = res;
					if(code - 200 === 0 || code -201 === 0){
						this.$setStorageSync('userInfo', data)
						this.$setStorageSync('satoken', data.tokenValue)
						if(code - 201 === 0){
							uni.navigateTo({
								url:'/subpackage/login/login'
							  })
						}
						if(code - 200 === 0){
							uni.reLaunch({
								url:'/pages/awaitOrder/index'
							  })
						}
					}else{
						uni.showToast({
							icon:'none',
							title: msg
						})
					}
					
				})
				// this.$refs.myPopup.open()
			}
		}
	}
</script>

<style lang="scss">
  .content{
	  height: 100%;
	  background-color: #F8F8F8;
	  overflow: hidden;
	  padding-top:30rpx ;
	  .form-item{
		  width: 90%;
		  margin: 0 auto;
		  border-bottom: 1px solid #f8f8f8;
		  font-size: 30rpx;
		  height: 80rpx;
		  line-height: 80rpx;
	  }
	  .popup-content{
	  	 	width: 550rpx;
	  	 	height: 300rpx;
	  	 	padding: 40rpx;
	  	 	background:#fff;
	  	 	border-radius: 10rpx;
	  	 	font-size: 24rpx;
	  	 	text-align: center;
	  	 	padding-top: 80rpx;
	  	 	background: #fff linear-gradient( 180deg, rgba(2,177,170,0.12) 0%, rgba(0,214,142,0) 20%);
	  	 	border-radius: 16rpx 16rpx 16rpx 16rpx;
	  	 	.popup-title{
	  	 		font-size: 32rpx;
	  	 		font-weight: 600;
	  	 		line-height: 40rpx;
	  	 	}
	  	 	.popup-tip-info{
	  	 		line-height: 180rpx;
	  	 	}
	  	 	.popup-btns{
	  	 		width: 500rpx;
	  	 		margin: 0 auto;
	  			display: flex;
	  	 		.btn{
	  	 			height: 80rpx;
	  	 			line-height: 80rpx;
	  	 			font-size: 26rpx;
	  	 			margin-bottom: 30rpx;
	  				width: 200rpx;
	  				background: #02B1AA;
	  				color: #fff;
	  	 		}
	  	 	}
	  	 }
  }
</style>
